﻿// <copyright file="ExpertMain.cs" company="Microsoft Corporation">
// Copyright (c) 2009 All Right Reserved
// </copyright>
//
// <author>Netmon Cipher Dev Team</author>
// <date>2009-07-16</date>
// <version>1.0</version>
// <summary>This contains the entry point Main function.</summary>

[assembly: System.CLSCompliant(true)]
namespace NetmonDecryptionExpert
{
    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    using Microsoft.NetworkMonitor.Automation;    

    /// <summary>
    /// Expert Main Class
    /// </summary>
    public static class ExpertMain
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">
        /// Arguments from Netmon UI
        /// </param>
        /// <returns>0 on Success, 1 on Any Failure</returns>
        [STAThread]
        public static int Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CommandLineArguments commandReader = new CommandLineArguments();
            commandReader.ParseCommandLineArguments(args);
            if (!commandReader.IsNoArguments)
            {
                DecryptionExpert frmMain = new DecryptionExpert(commandReader);
                Application.Run(frmMain);

                return frmMain.WasError ? 1 : 0;
            }
            else
            {
                if (!commandReader.IsSuppressingErrors)
                {
                    MessageBox.Show("Expert Requires at least a Filename Parameter", "Error");
                }       
         
                return 1;
            }
        }
    }
}
